package newsLikeService

import (
	"gin/dao/entity"
	"gin/dao/mapper/news"
	"gin/dao/mapper/news/newsLike"
)

// Add 动态添加点赞
func Add(uid, id int64) {
	info := newsLike.GetById(id, uid)
	if info.Id != 0 {
		newsLike.Del(id, uid)
		news.UpdateNum(id, 2, false)
	} else {
		newsLike.Add(entity.NewsLike{
			NewsId: id,
			Uid:    uid,
		})
		news.UpdateNum(id, 2, true)
	}
	news.UpdateNum(id, 1, true)
}
